﻿using System;
using System.Windows;
using Csla.Xaml;
using Accounting.Library;

namespace csla4Skeleton.UI.SL.TongHop.TH_KyKetChuyen
{
    public partial class TH_KyKetChuyen_ListViewModel : ViewModel<Accounting.Library.TH_KyKetChuyenList>
    {
        public TH_KyKetChuyen_ListViewModel(string mode)
        {
            BeginRefresh("GetTH_KyKetChuyenList", mode);

        }

        public void GetTH_KyKetChuyen_ListViewModel(string mode)
        {
            BeginRefresh("GetTH_KyKetChuyenList", mode);
        }

        public static readonly DependencyProperty SelectedItemProperty =
            DependencyProperty.Register("SelectedItem", typeof(TH_KyKetChuyenInfo), typeof(TH_KyKetChuyen_ListViewModel), null);
        public TH_KyKetChuyenInfo SelectedItem
        {
            get { return (TH_KyKetChuyenInfo)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        public void DeleteTH_KyKetChuyen(object sender, ExecuteEventArgs e)
        {
            if (e.MethodParameter != null)
            {
                //cast OrderID parameter
                int orderID = Int16.Parse(e.MethodParameter.ToString());
                this.IsBusy = true;
                Accounting.Library.TH_KyKetChuyen.DeleteTH_KyKetChuyen(orderID, (o, ex) =>
                {
                    BeginRefresh("GetTH_KyKetChuyenList", BusinessConfiguration.Configuration.GridViewFetchMode);
                });
                this.IsBusy = false;
            }
        }	
    }
}
